package threadpoolexecutor;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ArrayBlockingQueue
 * @Author : 54061
 * @Date: 2022/2/16 19:49
 */
public class ArrayBlockingQueueDemo {
    public static void main(String[] args) throws InterruptedException{
        //创建集合对象
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(3);
        //添加元素
        queue.put("张三丰");
        queue.put("张翠山");
        queue.put("张无忌");
        /*queue.put("张无忌");*/
        System.out.println("queue = " + queue);
        //取出元素(移除队列的头)
        System.out.println("queue.take() = " + queue.take());
        System.out.println("queue.take() = " + queue.take());
        System.out.println("queue.take() = " + queue);
        System.out.println("queue.take() = " + queue.take());
        System.out.println("queue.take() = " + queue.take());
    }
}
